import {Entity, PrimaryGeneratedColumn, Column, OneToMany} from 'typeorm';
import {Task} from "./task";

@Entity()
export class User {
    @PrimaryGeneratedColumn() // 自增主键
    id: number;

    @Column() // Column 普通列
    name: string;// js 数据类型

    @Column({type: 'int'}) // type 数据库键类型
    age: number;


    @Column({nullable: true}) // Column 普通列
    address: string;

    todoCount: number;//TODO

    //定义表关系, @OneToMany不可以单独出现，对应的Task实体中必须存在对应的@ManyToOne修饰的属性user
    @OneToMany(() => Task, task => task.user)
    tasks: Task[];
}
